#include "test.h"

int uart_open(int comport);
int uart_setting(int fd, int baud_rate, int data_bit, char parity_bit, int stop_bit);

int test_uart()
{
    printf("---------测试uart功能--------------");
    int fd;
    // 没有检测是否打开、配置成功，如果错误就没有抛出对应的异常
    fd = uart_open(0);
    uart_setting(fd, 9600, 8, 'N', 1);
    char buff[BUFFER_SIZE];
    do
	{
		memset(buff, 0, BUFFER_SIZE);
		if (read(fd, buff, strlen(buff)) > 0)
		{
			printf("The received words are : %s\n", buff);
            write(fd, buff, strlen(buff));
		}
	} while(strncmp(buff, "quit", 4));
    close(fd);

    return 0;
}